import { ref, reactive, onMounted, onUnmounted } from 'vue'

function savePoint() {
  // 实现鼠标“打点”相关数据
  let point = reactive({
    x: 0,
    y: 0
  })

  // 实现鼠标“打点”相关方法
  function savePoint(e) {
    point.x = e.clientX
    point.y = e.clientY
    console.log(point.x, point.y)
  }

  // 实现鼠标“打点”相关生命周期
  onMounted(() => {
    document.addEventListener('click', savePoint)
  })

  onUnmounted(() => {
    document.removeEventListener('click', savePoint)
  })

  return point
}

export default savePoint